﻿using IMES.Common.Domain.SirModel;
using IMES.Common.Dtos;
using IMES.Common.Infrastructure;
using MediatR;

namespace GlennQuigmire.API.Application.Commands
{
    public class InboundOrderPrintHander : IRequestHandler<InboundOrderPrintCommand, Result>
    {

        private readonly IBaseRepositorys<InboundOrder> baseRepositorys;

        public InboundOrderPrintHander(IBaseRepositorys<InboundOrder> baseRepositorys)
        {
            this.baseRepositorys = baseRepositorys;
        }

        /// <summary>
        /// 查询入库单（打印）
        /// </summary>
        /// <param name="request">打印入库单请求对象</param>
        /// <param name="cancellationToken">允许取消的取消标记</param>
        /// <returns>返回打印的入库单信息</returns>
        public Task<Result> Handle(InboundOrderPrintCommand request, CancellationToken cancellationToken)
        {
            var result = new Result();
            var list = baseRepositorys.GetAll().FirstOrDefault(c => c.InboundOrderNumber == request.InboundOrderNumber && !c.DeleteDate);
            result.Data = list;
            return Task.FromResult(result);
        }
    }
}
